package com.cloud.redis7;

import com.google.common.hash.BloomFilter;
import com.google.common.hash.Funnels;
import org.junit.Test;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import tk.mybatis.spring.annotation.MapperScan;


/**
 * @auther
 * @create
 */
@SpringBootApplication
@MapperScan("com.cloud.redis7.mapper") //import tk.mybatis.spring.annotation.MapperScan;
public class Redis7Study {
    public static void main(String[] args) {
        SpringApplication.run(Redis7Study.class, args);
    }

    @Test
    public void testGuavaWithBloomFilter() {
// 创建布隆过滤器对象
        BloomFilter<Integer> filter = BloomFilter.create(Funnels.integerFunnel(), 100);
// 判断指定元素是否存在
        System.out.println(filter.mightContain(1));
        System.out.println(filter.mightContain(2));
// 将元素添加进布隆过滤器
        filter.put(1);
        filter.put(2);
        System.out.println(filter.mightContain(1));
        System.out.println(filter.mightContain(2));
    }


}